<?php
   if(isset($query)){
       if($query->num_rows > 0){
           $news_data = $query->row();
  
       }
   }
?>

<div id=content_wrapper>
    <h1>News</h1>
    <img src="<?php echo base_url().'/assets/thumbs/'.$news_data->image?>"></img>
    <h2><?php echo $news_data->title; ?></h2>
    <p>Date post :<?php echo $news_data->date_post; ?></p>
    <p><?php echo $news_data->content; ?></p>
 
</div>
<div id="commentNews">
    <?php 
        if(isset($comment_news) && ($comment_news != NULL)){
            foreach($comment_news as $comment_data){
            ?>
            <div id="commentAuthor">
            <p>Commented by :<span class="userComment"><?php echo $comment_data['user_name'];?></span></p>
            <p>date :<span class="userComment"><?php echo $comment_data['date_comment'];?></span></p>
            
            <p class="comment"><?php echo $comment_data['comment'] ?></p>
            </div>
            
            <?php    
            }
        }
    ?>
    
</div>

<div id=commentForm>
<?php 
$userid = $this->session->userdata('userid');
if($userid!=NULL && (isset($userid))){
?>
<div id="Form">
    <fieldset>
        <legend>Comment</legend>
        <p>After comment, your comment will be checked before posted !</p>
        <form id="commentForm" name="commentForm" action="<?php echo site_url('home/add_comment_news').'/'.$news_data->id?>" method="post">
        <?php echo form_error('comment');?>
        <textarea id="comment" name="comment" cols="40" rows="2">

        </textarea>
        <input type="submit" id="postComment" name="postComment" value="Comment"/>
        </form>
    </fieldset>
</div>
</div><!--End #commentForm-->
<div>
<?php } else {
    echo "<p>You must login to comment</p>";
}?>
</div>




    
        
        
        
        
